package main

import (
	"fmt"
	"net"
	"time"
)

func main() {
	conn, err := net.Dial("tcp", ":9999")
	if err != nil {
		panic(err)
	}

	fmt.Println("成功连接到服务器")
	fmt.Println(conn)
	fmt.Printf("%+v\n", conn)
	i := 1
	for {
		if i > 20 {
			err := conn.Close()
			if err != nil {
				panic(err)
			}
		}
		i++
		fmt.Println("foo")
		time.Sleep(time.Second * 2)
	}
}
